import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

const pathResolve = (dir: string): any => {

  return resolve(__dirname, '.', dir)
}
const alias: Record<string, string> = {
  '/@': pathResolve('./src/'),
  assets: pathResolve('./src/assets')
}
// https://vitejs.dev/config/
export default defineConfig({
  base: '/',
  resolve: { alias },
  plugins: [vue()],
  server: {
    host: '0.0.0.0', // 这个用于启动
    port: 8092, // 指定启动端口
    open: true, //启动后是否自动打开浏览器
    proxy: {
      '/api': {
        target: 'http://kmapi.com/',
        changeOrigin: true,
      },
    }
  },
  build: {
    cssCodeSplit: false,
    sourcemap: false,
    emptyOutDir: true,
    chunkSizeWarningLimit: 1500,
    rollupOptions: {
        output: {
            manualChunks: {
                // 分包配置，配置完成自动按需加载
                vue: ['vue', 'vue-router', 'pinia','element-plus']
            },
        },
    },
},
})

